type Result [out T, out E] enum {
    type Success weak T;
    type Failure weak E;
};

export function Success:
    [T] &(T) => Result[T,never]
    &(t) => { |Result| { |Success[T,never]| t } };

export function Failure:
    [T] &(T) => Result[never,T]
    &(t) => { |Result| { |Failure[never,T]| t } };

export function map:[A,B,E]
    &(Result[A,E], &(A) => B) => Result[B,E]
    &(ra, f) =>
        switch ra:
        case Success a:
            { Success { f(a) } },
        case Failure err:
            { Failure err },
        end;


